# python当中的元组
'''
tuple1 = ('mysql','sqlserver','oracle','sqlite','postgresql','db2','ocean base')
tuple2 = ('redis', 'mongodb', 'memcached')
# 遍历

for i in tuple1:
    print(i)

# 索引切片 
print(tuple2[-1])
print(tuple1[0])

# 与列表进行转换
tuple1 = list(tuple1)
tuple1[0] = 'mariadb'
tuple1 = tuple(tuple1)
print(tuple1)
'''

# python中的常用方法
'''
print(len('hello world'))  # 数据长度
print(sum([5,12,55,11,33])) # 求和
print(max([1,2,3,4,5]))    # 最大值
print(min([1,2,3,4,5]))    # 最小值
a = [1,2,3,4,5]
del a[-1]                  # 删除
print(a)
'''
'''
# python的集合类型
# 注意，定义空集合使用 set()
# a = {5,2,3,4,1,1,1,5,3,2}
# print(a)

# 列表去重

a = [5,2,3,4,1,1,1,5,3,2]
b = []
for r in a:
    if r not in b:
        b.append(r)
print(b)

set1 = {'mysql','sqlserver','oracle','sqlite','postgresql','db2','ocean base'}
set2 = {'redis', 'mongodb', 'memcached','sqlite','db2','oracle'}
# print(set1 - set2) # 差集
# print(set2 - set1)
# print(set1 | set2) # 并集
# print(set1 & set2) # 交集
# print(set1 ^ set2) # 对称差集

# 集合操作
set2 = {'redis', 'mongodb', 'memcached','sqlite','db2','oracle'}
set2.add('linux')
set2.discard('db2')
set2.remove('sqlite')
set3 = {1,2,3,4,5}
set3.pop()
set3.pop()
print(set3)
set2.update([1,2,3,4,5])
print(set2)
'''

'''
# python 中的字典类型

# 定义
dict1 = {'姓名': "张三", '性别': '男', '年龄': '25', '爱好': ['打球', '游戏', '吃']}

# 给字典添加键值对
dict1['工作'] = '工人'

# 删除字典中的元素
del dict1['爱好']

# 修改字典中的数据
dict1['性别'] = '女'

print(dict1['姓名'])
print(dict1)
'''
'''
info = ['姓名','性别','年龄','工作']
dict2 = {}.fromkeys(info, "未填写") # 初始化一个字典
print(dict2)
'''

dict1 = {'姓名': "张三", '性别': '男', '年龄': '25', '爱好': ['打球', '游戏', '吃']}
# # print(dict1['工资'])
# print(dict1.setdefault('工资', '未找到该信息')) # get 是查找，如果没有返回默认值，setdefault 是查找，如果没有则返回默认值并在原字典中设置对应的键值对
# print(dict1)

# 遍历字典
for k,v in dict1.items():
     print(k,'---->',v)
'''
# 给字典增加元素
dict1.update({'a':'b','c': 'd'})
print(dict1)
a = {[1,2,3]: 'hello'}
print(a)
'''